﻿var allowFileTypes = allowFileTypes || '*.gif; *.txt; *.jpg; *.bmp; *.png; *.mp3; *.xls; *.doc; *.pdf; *.rar; *.zip; *.xlsx; *.docx;';
var acceptFileTypes = acceptFileTypes || /(\.|\/)(jpe?g|png|bmp)$/i;
var FileUrlString = "~/Public/attachment/";


(function ($) {

    app.modals.CreateOrEditModal = function () {
        $('#fileupload1').fileupload({
            maxFileSize: 50 * 1024 * 1024,
            url: '/BaseManage/UpLoader/Upload?UpLoadUrl=' + FileUrlString,
            dataType: 'json',
            messages: {
                maxFileSize: '文件大小不允许超过 ' + 10 + 'MB',
                acceptFileTypes: '请上传' + allowFileTypes + '格式文件'
            }, success: function (data, status)  //服务器成功响应处理函数
            {
                debugger;
                var file = $("#CompanyOrganization").val();
                var fileValue = file + "," + data.result.fileName;
                //把上传的文件名，赋值给文本框
                $("#CompanyOrganization").val(data.result.fileName);

                var array = [];
                var dataInsert = {
                    FileName: data.result.fileName,
                    Size: data.result.size,
                    IsDefault: false,
                    Url: data.result.fileSaveName
                };
                array.push(dataInsert);
                var FileTemp = $("#FileList").val();
                if (FileTemp != "") {
                    var jsObject = JSON.parse(FileTemp);
                    array.push.apply(array, jsObject);   //把多个数组合并,不改变原结构
                }
                //存入
                $("#FileList").val(JSON.stringify(array));
                
                console.log(data);
            }, error: function (data, status, e)//服务器响应失败处理函数
            {
                alert("上传失败!" + data.result.fileName);
            }
        })
        //注册信息--电话号码是否正确
        $("#LinkTel").change(function () {
            var val = $("#LinkTel").val();
            if (!(/^1[34578]\d{9}$/.test(val))) {
                alert(app.localize('LinkTel') + app.localize('Not a valid call'));
                $("#LinkTel").val("");
            }
        });
        //注册信息--办公室座机
        $("#OfficePhone").change(function () {
            var tel = $("#OfficePhone").val();
            var ph = /^(0|86|17951)?(13[0-9]|15[012356789]|17[01678]|18[0-9]|14[57])[0-9]{8}$/;
            if (!ph.test(tel)) {
                alert(app.localize('OfficePhone') + app.localize('Not a valid call'));
                $("#OfficePhone").val("");
            }
        });
        //注册信息--邮箱是否正确
        var temp = document.getElementById("txtemail");
        //对电子邮件的验证
        $("#Email").change(function () {
            var value = $("#Email").val();
            var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
            if (!myreg.test(value)) {
                alert(app.localize('Email') + app.localize('Not a valid Email'));
                $("#Email").val("");
            }
        });
        //财务信息-注册资金
        $("#RegisteredAmount").change(function () {
            var val = $("#RegisteredAmount").val();   //根据id 获取字段的值
            //  $("#RegisteredAmount").attr("readonly","readonly");   //设置字段为自读
            if (!isNaN(val)) {
                return true;
            } else {
                alert(app.localize('RegisteredAmount') + app.localize('It can only be numbers'));
                $("#RegisteredAmount").val(0.00);
            }
        });
        //供应商业务信息-验证是否上市
        $("#IsListed").change(function () {
            var val = $("#IsListed").attr('checked');   //根据id 获取字段的值
            if (val != "checked") {
                $("#ListedPlace").attr("readonly", "readonly");
                $("#ListedTime").attr("readonly", "readonly");
            }
            else {
                $("#ListedPlace").attr("", "");
                $("#ListedTime").attr("", "");
            }
        });



        var _modalManager;
        var _gvService = abp.services.app.s_Provider_Register;
        var MainId = $('input[name="Id"]').val() || 0;
        var _$studentModelInformationForm = null;
        //供应商联系人
        $('#ContactTable').bootstrapTable({
            url: "/BaseManage/ProviderRegister/GetContactDetailJosn?id=" + MainId + "&Flag=" + MainId, //请求后台的URL（*）
            method: 'Get', //请求方式（*）
            striped: true, //是否显示行间隔色
            cache: false, //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
            pagination: false, //是否显示分页（*）
            //sidePagination: 'server',//分页方式
            sortable: true, //是否启用排序
            sortOrder: "asc", //排序方式
            pageNumber: 1, //初始化加载第一页，默认第一页
            pageSize: 10, //每页的记录行数（*）
            pageList: [10, 50, 100, 200], //可供选择的每页的行数（*）
            minimumCountColumns: 1, //最少允许的列数
            //clickToSelect: true, //是否启用点击选中行
            height: 250, //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
            uniqueId: "Xh", //每一行的唯一标识，一般为主键列
            editable: true, //开启编辑模式
            rowStyle: function (row, index) {
                var style = {};
                style = { css: { 'white-space': 'nowrap' } };
                return style;
            },
            columns: [
                {
                    field: "action", title: app.localize('Actions'), formatter: function (value, row, rowIndex, data) {
                        var html = '<a class="ie-inline-block margin-r10" onclick="addRowbtn(' + rowIndex + ')" title="插入"><span class="ui-icon ui-icon-plus inline-block"></span></a>'
                            + '<a class="ie-inline-block margin-r10"  onclick="removeRow(' + rowIndex + ')" title="删除"><span class="ui-icon ui-icon-trash inline-block"></span></a>';
                        return html;
                    }, edit: false, width: 50
                },
                {
                    field: "Job", title: app.localize('Job'), align: "center"
                },
                { field: "Dept", title: app.localize('Dept'), align: "center" },
                { field: "LinkMan", title: app.localize('LinkMan'), align: "center" },
                { field: "Tel", title: app.localize('Tel'), align: "center" },
                { field: "JobTime", title: app.localize('JobTime'), align: "center" },
                { field: "QQ", title: app.localize('QQ'), align: "center" },
                {
                    field: "LinkTel",
                    title: app.localize('LinkTel'),
                    align: "center"
                },
                { field: "LinkAdress", title: app.localize('LinkAdress'), align: "center" },
                { field: "Mailbox", title: app.localize('Mailbox'), align: "center" },
                { field: "Remark", title: app.localize('Remark'), align: "center" }
            ]
        });
        //编辑表格 供应商资本构成
        $('#CapitalTable').bootstrapTable({
            url: "/BaseManage/ProviderRegister/GetCapitalDetailJosn?id=" + MainId + "&Flag=" + MainId, //请求后台的URL（*）
            method: 'Get', //请求方式（*）
            striped: true, //是否显示行间隔色
            cache: false, //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
            pagination: false, //是否显示分页（*）
            //sidePagination: 'server',//分页方式
            sortable: true, //是否启用排序
            sortOrder: "asc", //排序方式
            pageNumber: 1, //初始化加载第一页，默认第一页
            pageSize: 10, //每页的记录行数（*）
            pageList: [10, 50, 100, 200], //可供选择的每页的行数（*）
            minimumCountColumns: 1, //最少允许的列数
            //clickToSelect: true, //是否启用点击选中行
            height: 250, //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
            uniqueId: "Xh", //每一行的唯一标识，一般为主键列
            editable: true, //开启编辑模式
            rowStyle: function (row, index) {
                var style = {};
                style = { css: { 'white-space': 'nowrap' } };
                return style;
            },
            columns: [
                {
                    field: "action", title: app.localize('Actions'), formatter: function (value, row, rowIndex, data) {
                        var html = '<a class="ie-inline-block margin-r10" onclick="addRowbtnCapital(' + rowIndex + ')" title="插入"><span class="ui-icon ui-icon-plus inline-block"></span></a>'
                            + '<a class="ie-inline-block margin-r10"  onclick="removeRowCapital(' + rowIndex + ')" title="删除"><span class="ui-icon ui-icon-trash inline-block"></span></a>';
                        return html;
                    }, edit: false, width: 50
                },
                { field: "PartnerName", title: app.localize('PartnerName'), align: "center" },
                { field: "Investment", title: app.localize('Investment'), align: "center" },
                { field: "ShareRatio", title: app.localize('ShareRatio'), align: "center" }
            ]
        });
        //编辑表格 供应商资质信息
        $('#QualificationsTable').bootstrapTable({
            url: "/BaseManage/ProviderRegister/GetQualificationsDetaiJosn?id=" + MainId, //请求后台的URL（*）
            method: 'Get', //请求方式（*）
            striped: true, //是否显示行间隔色
            cache: false, //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
            pagination: false, //是否显示分页（*）
            //sidePagination: 'server',//分页方式
            sortable: true, //是否启用排序
            sortOrder: "asc", //排序方式
            pageNumber: 1, //初始化加载第一页，默认第一页
            pageSize: 10, //每页的记录行数（*）
            pageList: [10, 50, 100, 200], //可供选择的每页的行数（*）
            minimumCountColumns: 1, //最少允许的列数
            //clickToSelect: true, //是否启用点击选中行
            height: 250, //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
            uniqueId: "Xh", //每一行的唯一标识，一般为主键列
            editable: true, //开启编辑模式
            rowStyle: function (row, index) {
                var style = {};
                style = { css: { 'white-space': 'nowrap' } };
                return style;
            },
            columns: [

                { field: "O_QualificationsCode", title: app.localize('O_QualificationsCode'), align: "center", edit: false, width: 50 },
                { field: "O_QualificationsNames", title: app.localize('QualificationsName'), align: "center", edit: false, },
                {
                    field: "PassDate", title: app.localize('PassDate'),  align: "center", edit: { type: "date" },
                },
                {
                    field: "CertificationUnit", title: app.localize('CertificationUnit'), align: "center", width: 100
                },
                {
                    field: "BeginDate", title: app.localize('BeginDate'), align: "center", edit: { type: "date" },
                    formatter: function (value, row, index) {
                        return changeDateFormatM(value)
                    },
                },
                {
                    field: "EndDate", title: app.localize('EndDate'), align: "center", edit: { type: "date" },
                    formatter: function (value, row, index) {
                        return changeDateFormatM(value)
                    },
                },
                {
                    field: "ApprovalNumber", title: app.localize('ApprovalNumber'), placeholder: app.localize('ApprovalNumber'),align: "center", width: 150
                }, {
                    field: "Describe", title: app.localize('Describe'), align: "center", width: 150
                },
                {
                    field: "Remark", title: app.localize('Remark'), align: "center", width: 150, edit: false
                },
                { field: "QualificationsId", title: app.localize('QualificationsId'), align: "center", edit: false, width: 50, visible: false },
            ]
        });
        //编辑表格 供应商经营状况
        $('#OperatingTable').bootstrapTable({
            url: "/BaseManage/ProviderRegister/GetOperatingDetailJosn?id=" + MainId, //请求后台的URL（*）
            method: 'Get', //请求方式（*）
            striped: true, //是否显示行间隔色
            cache: false, //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
            pagination: false, //是否显示分页（*）
            //sidePagination: 'server',//分页方式
            sortable: true, //是否启用排序
            sortOrder: "asc", //排序方式
            pageNumber: 1, //初始化加载第一页，默认第一页
            pageSize: 10, //每页的记录行数（*）
            pageList: [10, 50, 100, 200], //可供选择的每页的行数（*）
            minimumCountColumns: 1, //最少允许的列数
            //clickToSelect: true, //是否启用点击选中行
            height: 250, //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
            uniqueId: "Xh", //每一行的唯一标识，一般为主键列
            editable: true, //开启编辑模式
            rowStyle: function (row, index) {
                var style = {};
                style = { css: { 'white-space': 'nowrap' } };
                return style;
            },
            columns: [
                { field: "O_CategoryCode", title: app.localize('CategoryCode'), align: "center", edit: false, width: 80 },
                { field: "O_CategoryNames", title: app.localize('CategoryName'), align: "center", edit: false, width: 80 },
                { field: "Describe", title: app.localize('Describe'), align: "center" },
                { field: "Remark", title: app.localize('Remark'), align: "center", edit: false },
                { field: "CategoryId", title: app.localize('CategoryId'), align: "center", edit: false, width: 50, visible: false }
            ]
        });
        //编辑表格 供应商配套能力
        $('#MatchingCapabilityTable').bootstrapTable({
            url: "/BaseManage/ProviderRegister/GetMatchingCapabilityAllJosn?id=" + MainId, //请求后台的URL（*）
            method: 'Get', //请求方式（*）
            striped: true, //是否显示行间隔色
            cache: false, //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
            pagination: false, //是否显示分页（*）
            //sidePagination: 'server',//分页方式
            sortable: true, //是否启用排序
            sortOrder: "asc", //排序方式
            pageNumber: 1, //初始化加载第一页，默认第一页
            pageSize: 10, //每页的记录行数（*）
            pageList: [10, 50, 100, 200], //可供选择的每页的行数（*）
            minimumCountColumns: 1, //最少允许的列数
            //clickToSelect: true, //是否启用点击选中行
            height: 250, //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
            uniqueId: "Xh", //每一行的唯一标识，一般为主键列
            editable: true, //开启编辑模式
            rowStyle: function (row, index) {
                var style = {};
                style = { css: { 'white-space': 'nowrap' } };
                return style;
            },
            columns: [
                { field: "O_MatchingCapabilityCode", title: app.localize('O_MatchingCapabilityCode'), align: "center", edit: false, width: 80 },
                { field: "O_MatchingCapabilityNames", title: app.localize('O_MatchingCapabilityNames'), align: "center", edit: false, width: 80 },
                { field: "Describe", title: app.localize('Describe'), align: "center" },
                { field: "Remark", title: app.localize('Remark'), align: "center", edit: false },
                { field: "MatchingCapabilityId", title: app.localize('MatchingCapabilityId'), align: "center", edit: false, width: 50, visible: false }
            ]
        });
        //编辑表格 供应商主要客户
        $('#CustomerTable').bootstrapTable({
            url: "/BaseManage/ProviderRegister/GetCustomerDetailJosn?id=" + MainId + "&Flag=" + MainId, //请求后台的URL（*）
            method: 'Get', //请求方式（*）
            striped: true, //是否显示行间隔色
            cache: false, //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
            pagination: false, //是否显示分页（*）
            //sidePagination: 'server',//分页方式
            sortable: true, //是否启用排序
            sortOrder: "asc", //排序方式
            pageNumber: 1, //初始化加载第一页，默认第一页
            pageSize: 10, //每页的记录行数（*）
            pageList: [10, 50, 100, 200], //可供选择的每页的行数（*）
            minimumCountColumns: 1, //最少允许的列数
            //clickToSelect: true, //是否启用点击选中行
            height: 250, //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
            uniqueId: "Xh", //每一行的唯一标识，一般为主键列
            editable: true, //开启编辑模式
            rowStyle: function (row, index) {
                var style = {};
                style = { css: { 'white-space': 'nowrap' } };
                return style;
            },
            columns: [
                {
                    field: "action", title: app.localize('Actions'), formatter: function (value, row, rowIndex, data) {
                        var html = '<a class="ie-inline-block margin-r10" onclick="addRowbtnCustomer(' + rowIndex + ')" title="插入"><span class="ui-icon ui-icon-plus inline-block"></span></a>'
                            + '<a class="ie-inline-block margin-r10"  onclick="removeRowCustomer(' + rowIndex + ')" title="删除"><span class="ui-icon ui-icon-trash inline-block"></span></a>';
                        return html;
                    }, edit: false, width: 50
                },
                { field: "CustomerName", title: app.localize('CustomerName'), align: "center" },
                { field: "Payment", title: app.localize('Payment'), align: "center" },
                { field: "PaymentTool", title: app.localize('PaymentTool'), align: "center" },
                { field: "PaymentResult", title: app.localize('PaymentResult'), align: "center" },
                { field: "CustomerHonor", title: app.localize('CustomerHonor'), align: "center" }
            ]
        });
        //编辑表格 供应商主要产品
        $('#ProductTable').bootstrapTable({
            url: "/BaseManage/ProviderRegister/GetProductDetailJosn?id=" + MainId + "&Flag=" + MainId, //请求后台的URL（*）
            method: 'Get', //请求方式（*）
            striped: true, //是否显示行间隔色
            cache: false, //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
            pagination: false, //是否显示分页（*）
            //sidePagination: 'server',//分页方式
            sortable: true, //是否启用排序
            sortOrder: "asc", //排序方式
            pageNumber: 1, //初始化加载第一页，默认第一页
            pageSize: 10, //每页的记录行数（*）
            pageList: [10, 50, 100, 200], //可供选择的每页的行数（*）
            minimumCountColumns: 1, //最少允许的列数
            //clickToSelect: true, //是否启用点击选中行
            height: 250, //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
            uniqueId: "Xh", //每一行的唯一标识，一般为主键列
            editable: true, //开启编辑模式
            rowStyle: function (row, index) {
                var style = {};
                style = { css: { 'white-space': 'nowrap' } };
                return style;
            },
            columns: [
                {
                    field: "action", title: app.localize('Actions'), formatter: function (value, row, rowIndex, data) {
                        var html = '<a class="ie-inline-block margin-r10" onclick="addRowbtnProduct(' + rowIndex + ')" title="插入"><span class="ui-icon ui-icon-plus inline-block"></span></a>'
                            + '<a class="ie-inline-block margin-r10"  onclick="removeRowProduct(' + rowIndex + ')" title="删除"><span class="ui-icon ui-icon-trash inline-block"></span></a>';
                        return html;
                    }, edit: false, width: 50
                },
                { field: "ProductName", title: app.localize('ProductName'), align: "center" },
                { field: "MaterialScience", title: app.localize('MaterialScience'), align: "center" },
                {
                    field: "TechniqueClassId", edit: {
                        type: 'select', //下拉框
                        data: eval('(' + $("#TechniqueClassJson").val() + ')'),
                        valueField: 'Value',
                        textField: 'DisplayText',
                        onSelect: function (val, rec) {
                            console.log(val, rec);
                        }
                    }, title: app.localize('TechniqueClass'), align: "center", width: 150
                },
                { field: "HostPlan", title: app.localize('HostPlan'), align: "center" },
                { field: "CarModel", title: app.localize('CarModelId'), align: "center" },
                { field: "SupplyQty", title: app.localize('SupplyQty'), align: "center" },
                { field: "Unit", title: app.localize('Unit'), align: "center" },
                { field: "ModelType", title: app.localize('ModelType'), align: "center" },
                { field: "MarketShare", title: app.localize('MarketShare'), align: "center" }
            ]
        });
        //编辑表格 产品质量
        $('#QualityTable').bootstrapTable({
            url: "/BaseManage/ProviderRegister/GetQualityDetailJosn?id=" + MainId, //请求后台的URL（*）
            method: 'Get', //请求方式（*）
            striped: true, //是否显示行间隔色
            cache: false, //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
            pagination: false, //是否显示分页（*）
            //sidePagination: 'server',//分页方式
            sortable: true, //是否启用排序
            sortOrder: "asc", //排序方式
            pageNumber: 1, //初始化加载第一页，默认第一页
            pageSize: 10, //每页的记录行数（*）
            pageList: [10, 50, 100, 200], //可供选择的每页的行数（*）
            minimumCountColumns: 1, //最少允许的列数
            //clickToSelect: true, //是否启用点击选中行
            height: 250, //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
            uniqueId: "Xh", //每一行的唯一标识，一般为主键列
            editable: true, //开启编辑模式
            rowStyle: function (row, index) {
                var style = {};
                style = { css: { 'white-space': 'nowrap' } };
                return style;
            },
            columns: [
                { field: "O_QualityProjectKPICode", title: app.localize('QualityProjectKPICode'), align: "center", edit: false, width: 50 },
                { field: "O_QualityProjectKPINames", title: app.localize('QualityProjectKPIName'), align: "center", edit: false, width: 100 },
                { field: "Product", title: app.localize('Product'), align: "center" },
                { field: "ProductSum", title: app.localize('ProductSum'), align: "center" },
                { field: "QualityProjectKPIId", title: app.localize('QualityProjectKPIId'), align: "center", edit: false, width: 50, visible: false },
            ]
        });
        //编辑表格 供应商主要生产设备
        $('#EquipmentTable').bootstrapTable({
            url: "/BaseManage/ProviderRegister/GetEquipmentDetailJosn?id=" + MainId, //请求后台的URL（*）
            method: 'Get', //请求方式（*）
            striped: true, //是否显示行间隔色
            cache: false, //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
            pagination: false, //是否显示分页（*）
            //sidePagination: 'server',//分页方式
            sortable: true, //是否启用排序
            sortOrder: "asc", //排序方式
            pageNumber: 1, //初始化加载第一页，默认第一页
            pageSize: 10, //每页的记录行数（*）
            pageList: [10, 50, 100, 200], //可供选择的每页的行数（*）
            minimumCountColumns: 1, //最少允许的列数
            //clickToSelect: true, //是否启用点击选中行
            height: 250, //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
            uniqueId: "Xh", //每一行的唯一标识，一般为主键列
            editable: true, //开启编辑模式
            rowStyle: function (row, index) {
                var style = {};
                style = { css: { 'white-space': 'nowrap' } };
                return style;
            },
            columns: [
                {
                    field: "action", title: app.localize('Actions'), formatter: function (value, row, rowIndex, data) {
                        var html = '<a class="ie-inline-block margin-r10" onclick="addRowbtnEquipment(' + rowIndex + ')" title="插入"><span class="ui-icon ui-icon-plus inline-block"></span></a>'
                            + '<a class="ie-inline-block margin-r10"  onclick="removeRowEquipment(' + rowIndex + ')" title="删除"><span class="ui-icon ui-icon-trash inline-block"></span></a>';
                        return html;
                    }, edit: false, width: 50
                },
                {
                    field: "EquipmentTypeId", edit: {
                        type: 'select', //下拉框
                        data: eval('(' + $("#EquipmentTypeIdJson").val() + ')'),
                        valueField: 'Value',
                        textField: 'DisplayText',
                        onSelect: function (val, rec) {
                            console.log(val, rec);
                        }
                    }, title: app.localize('EquipmentTypeId'), align: "center", width: 150
                },
                { field: "Manufacturer", title: app.localize('Manufacturer'), align: "center", width: 100 },
                {
                    field: "ManufactureDate", title: app.localize('ManufactureDate'), align: "center", edit: { type: "date" },
                    formatter: function (value, row, index) {
                        return changeDateFormatM(value)
                    }, width: 150
                },
                { field: "Spec", title: app.localize('Spec'), align: "center" },
                { field: "Capacity", title: app.localize('Capacity'), align: "center" },
                { field: "UsageRate", title: app.localize('UsageRate'), align: "center" },
                { field: "YearOld", title: app.localize('YearOld'), align: "center" },
            ]
        });
        //编辑表格 供应商主要检测设备
        $('#DetectionTable').bootstrapTable({
            url: "/BaseManage/ProviderRegister/GetDetectionDetailJosn?id=" + MainId + "&Flag=" + MainId, //请求后台的URL（*）
            method: 'Get', //请求方式（*）
            striped: true, //是否显示行间隔色
            cache: false, //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
            pagination: false, //是否显示分页（*）
            //sidePagination: 'server',//分页方式
            sortable: true, //是否启用排序
            sortOrder: "asc", //排序方式
            pageNumber: 1, //初始化加载第一页，默认第一页
            pageSize: 10, //每页的记录行数（*）
            pageList: [10, 50, 100, 200], //可供选择的每页的行数（*）
            minimumCountColumns: 1, //最少允许的列数
            //clickToSelect: true, //是否启用点击选中行
            height: 250, //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
            uniqueId: "Xh", //每一行的唯一标识，一般为主键列
            editable: true, //开启编辑模式
            rowStyle: function (row, index) {
                var style = {};
                style = { css: { 'white-space': 'nowrap' } };
                return style;
            },
            columns: [
                {
                    field: "action", title: app.localize('Actions'), formatter: function (value, row, rowIndex, data) {
                        var html = '<a class="ie-inline-block margin-r10" onclick="addRowbtnDetection(' + rowIndex + ')" title="插入"><span class="ui-icon ui-icon-plus inline-block"></span></a>'
                            + '<a class="ie-inline-block margin-r10"  onclick="removeRowDetection(' + rowIndex + ')" title="删除"><span class="ui-icon ui-icon-trash inline-block"></span></a>';
                        return html;
                    }, edit: false, width: 50
                },
                { field: "Type", title: app.localize('Type'), align: "center", width: 100 },
                { field: "Details", title: app.localize('Details'), align: "center", width: 100 },
                { field: "Spec", title: app.localize('Spec'), align: "center" },
                { field: "Year", title: app.localize('Year'), align: "center", width: 100 },
                { field: "Product", title: app.localize('Product'), align: "center" },
            ]
        });
        //编辑表格 供应商专用工装
        $('#PurposeToolingTable').bootstrapTable({
            url: "/BaseManage/ProviderRegister/GetPurposeToolingDetailJosn?id=" + MainId + "&Flag=" + MainId, //请求后台的URL（*）
            method: 'Get', //请求方式（*）
            striped: true, //是否显示行间隔色
            cache: false, //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
            pagination: false, //是否显示分页（*）
            //sidePagination: 'server',//分页方式
            sortable: true, //是否启用排序
            sortOrder: "asc", //排序方式
            pageNumber: 1, //初始化加载第一页，默认第一页
            pageSize: 10, //每页的记录行数（*）
            pageList: [10, 50, 100, 200], //可供选择的每页的行数（*）
            minimumCountColumns: 1, //最少允许的列数
            //clickToSelect: true, //是否启用点击选中行
            height: 250, //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
            uniqueId: "Xh", //每一行的唯一标识，一般为主键列
            editable: true, //开启编辑模式
            rowStyle: function (row, index) {
                var style = {};
                style = { css: { 'white-space': 'nowrap' } };
                return style;
            },
            columns: [
                {
                    field: "action", title: app.localize('Actions'), formatter: function (value, row, rowIndex, data) {
                        var html = '<a class="ie-inline-block margin-r10" onclick="addRowbtnTooling(' + rowIndex + ')" title="插入"><span class="ui-icon ui-icon-plus inline-block"></span></a>'
                            + '<a class="ie-inline-block margin-r10"  onclick="removeRowTooling(' + rowIndex + ')" title="删除"><span class="ui-icon ui-icon-trash inline-block"></span></a>';
                        return html;
                    }, edit: false, width: 50
                },
                { field: "ToolingName", title: app.localize('ToolingName'), align: "center", width: 200 },
                {
                    field: "ToolingType", title: app.localize('ToolingType'), align: "center", edit: false, width: 50,
                    formatter: function (val, rowData, index) {
                        if (val == true) {
                            return "<input type='checkbox' checked='checked'  name='ToolingType' id='ToolingType" + index + "' onclick='ToolingTypeCheck(" + index + ")' ></input>";
                        } else {
                            return "<input type='checkbox'  name='IsStandard' id='ToolingType" + index + "' onclick='ToolingTypeCheck(" + index + ")' ></input>";
                        }
                    } },
                {
                    field: "IsStandard", title: app.localize('IsStandard'), align: "center", edit: false, width: 50,
                    formatter: function (val, rowData, index) {
                        if (val == true) {
                            return "<input type='checkbox' checked='checked'  name='IsStandard' id='IsStandard" + index + "' onclick='IsStandardCheck(" + index + ")' ></input>";
                        } else {
                            return "<input type='checkbox'  name='IsStandard' id='IsStandard" + index + "' onclick='IsStandardCheck(" + index + ")' ></input>";
                        }
                    }
                },
                { field: "EnableTime", title: app.localize('EnableTime'), align: "center", width: 200, edit: { type: "date" } },
                { field: "EnableCode", title: app.localize('EnableCode'), align: "center" },
            ]
        });
        //编辑表格 其他信息
        $('#OtherTable').bootstrapTable({
            url: "/BaseManage/ProviderRegister/GetOtherDetailJosn?id=" + MainId, //请求后台的URL（*）
            method: 'Get', //请求方式（*）
            striped: true, //是否显示行间隔色
            cache: false, //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
            pagination: false, //是否显示分页（*）
            //sidePagination: 'server',//分页方式
            sortable: true, //是否启用排序
            sortOrder: "asc", //排序方式
            pageNumber: 1, //初始化加载第一页，默认第一页
            pageSize: 10, //每页的记录行数（*）
            pageList: [10, 50, 100, 200], //可供选择的每页的行数（*）
            minimumCountColumns: 1, //最少允许的列数
            //clickToSelect: true, //是否启用点击选中行
            height: 250, //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
            uniqueId: "Xh", //每一行的唯一标识，一般为主键列
            editable: true, //开启编辑模式
            rowStyle: function (row, index) {
                var style = {};
                style = { css: { 'white-space': 'nowrap' } };
                return style;
            },
            columns: [
                { field: "O_OtherProjectCode", title: app.localize('OtherProjectCode'), align: "center", edit: false, width: 80 },
                { field: "O_OtherProjectNames", title: app.localize('OtherProjectName'), align: "center", edit: false, width: 100 },
                { field: "Describe", title: app.localize('Describe'), align: "center" },
                { field: "Remark", title: app.localize('Remark'), align: "center" },
                { field: "OtherProjectId", title: app.localize('OtherProjectId'), align: "center", edit: false, width: 50, visible: false },
            ]
        });

        this.init = function (modalManager) {
            var data = {
                useCurrentPage: false
            };

            _modalManager = modalManager;
            _$studentModelInformationForm = _modalManager.getModal().find("form[name=InformationForm]");
            _$FinancialModelInformationForm = _modalManager.getModal().find("form[name=FinancialInformationForm]");
            _$BusinessModelInformationForm = _modalManager.getModal().find("form[name=BusinessInformationForm]");
            _$PeopleModelInformationForm = _modalManager.getModal().find("form[name=PeopleInformationForm]");
        }

        this.save = function () {
            debugger;
            var data = {
                useCurrentPage: false
            };
            var ContactModel = $('#ContactTable').bootstrapTable('getData', data);
            var CapitalModel = $('#CapitalTable').bootstrapTable('getData', data);
            var QualificationsModel = $('#QualificationsTable').bootstrapTable('getData', data);
            var OperatingModel = $('#OperatingTable').bootstrapTable('getData', data);
            var CustomerModel = $('#CustomerTable').bootstrapTable('getData', data);
            var ProductModel = $('#ProductTable').bootstrapTable('getData', data);
            var QualityModel = $('#QualityTable').bootstrapTable('getData', data);
            var EquipmentModel = $('#EquipmentTable').bootstrapTable('getData', data);
            var DetectionModel = $('#DetectionTable').bootstrapTable('getData', data);
            var OtherModel = $('#OtherTable').bootstrapTable('getData', data);
            var PurposeToolingTable = $('#PurposeToolingTable').bootstrapTable('getData', data);
            var MatchingCapabilityTable = $('#MatchingCapabilityTable').bootstrapTable('getData', data);
            var S_Provider_RegisterFile = $("#FileList").val();
            
            if (!_$studentModelInformationForm.valid()) {
                return;
            }
            var providerRegisterModel = _$studentModelInformationForm.serializeFormToObject();
            var FinancialModel = _$FinancialModelInformationForm.serializeFormToObject();
            var BusinessModel = _$BusinessModelInformationForm.serializeFormToObject();
            var PeopleModel = _$PeopleModelInformationForm.serializeFormToObject();

            //多选(物料类型)
            var materialTypeId = $("input[name='MaterialTypeId']:checked");
            var materialTypeIdJson = [];
            var Value = "";
            for (let i = 0; i < materialTypeId.length; i++) {
                materialTypeIdJson.push($(materialTypeId[i]).val());
                Value += $(materialTypeId[i]).val() + ",";
            }
            var MaterialTypeValue = Value.substring(0, Value.lastIndexOf(','));
            BusinessModel.MaterialTypeId = MaterialTypeValue;   //JSON.stringify(materialTypeIdJson);

            //多选(工艺分类)
            var techniqueClassId = $("input[name='TechniqueClassId']:checked");
            var Value = "";
            for (let i = 0; i < techniqueClassId.length; i++) {
                Value += $(techniqueClassId[i]).val() + ",";
            }
            var TechniqueClassIdValue = Value.substring(0, Value.lastIndexOf(','));
            BusinessModel.TechniqueClassId = TechniqueClassIdValue;
            //多选(运输方式)
            var transportClass = $("input[name='TransportClass']:checked");
            var Value = "";
            for (let i = 0; i < transportClass.length; i++) {
                Value += $(transportClass[i]).val() + ",";
            }
            var TransportClassValue = Value.substring(0, Value.lastIndexOf(','));
            BusinessModel.TransportClass = TransportClassValue;

            providerRegisterModel.S_Provider_RegisterContact = ContactModel;
            providerRegisterModel.S_Provider_RegisterBusiness = BusinessModel;
            providerRegisterModel.S_Provider_RegisterFinancial = FinancialModel;
            providerRegisterModel.S_Provider_RegisterCapital = CapitalModel;
            providerRegisterModel.S_Provider_RegisterPeople = PeopleModel;
            providerRegisterModel.S_Provider_RegisterQualifications = QualificationsModel;
            providerRegisterModel.S_Provider_RegisterOperating = OperatingModel;
            providerRegisterModel.S_Provider_RegisterCustomer = CustomerModel;
            providerRegisterModel.S_Provider_RegisterProduct = ProductModel;
            providerRegisterModel.S_Provider_RegisterQuality = QualityModel;
            providerRegisterModel.S_Provider_RegisterEquipment = EquipmentModel;
            providerRegisterModel.S_Provider_RegisterDetection = DetectionModel;
            providerRegisterModel.S_Provider_RegisterOther = OtherModel;
            providerRegisterModel.S_Provider_MatchingCapability = MatchingCapabilityTable;
            providerRegisterModel.S_SpecialPurposeTooling = PurposeToolingTable;
            providerRegisterModel.S_Provider_RegisterFileJson = S_Provider_RegisterFile;


            _modalManager.setBusy(true);
            var ss = jQuery.isEmptyObject(ContactModel);
            _gvService.createOrUpdateAsync({
                s_Provider_RegisterEditDto: providerRegisterModel
            }).done(function () {
                //  提示信息
                abp.notify.info(app.localize('SavedSuccessfully'));
                //关闭窗体
                _modalManager.close();
                //信息保存成功后调用事件，刷新列表
                abp.event.trigger('app.createOrEditModalSaved');
            }).always(function () {
                _modalManager.setBusy(false);
            });
        }


        //成立日期
        $('#SetUpDateSelect').datetimepicker({
            weekStart: 1,
            todayBtn: 1,
            autoclose: 1,
            todayHighlight: 1,
            startView: 2,
            forceParse: 0,
            language: 'zh-CN',
            //format: 'yyyy-mm-dd hh:ii:ss',
            pickerPosition: 'bottom-left',
            showMeridian: 1,
            //lk 只选择日期不选择时间
            format: 'yyyy-mm-dd',
            minView: "month",
            todayBtn: true
        });
        //注册日期
        $('#RegisterDateSelect').datetimepicker({
            weekStart: 1,
            todayBtn: 1,
            autoclose: 1,
            todayHighlight: 1,
            startView: 2,
            forceParse: 0,
            language: 'zh-CN',
            //format: 'yyyy-mm-dd hh:ii:ss',
            pickerPosition: 'bottom-left',
            showMeridian: 1,
            //lk 只选择日期不选择时间
            format: 'yyyy-mm-dd',
            minView: "month",
            todayBtn: true
        });
        //上市时间
        $('#ListedTimeSelect').datetimepicker({
            weekStart: 1,
            todayBtn: 1,
            autoclose: 1,
            todayHighlight: 1,
            startView: 2,
            forceParse: 0,
            language: 'zh-CN',
            //format: 'yyyy-mm-dd hh:ii:ss',
            pickerPosition: 'bottom-left',
            showMeridian: 1,
            //lk 只选择日期不选择时间
            format: 'yyyy-mm-dd',
            minView: "month",
            todayBtn: true
        });

    }
})(jQuery);

//转换日期格式(时间戳转换为datetime格式)
function changeDateFormatM(cellval) {
    var dateVal = cellval + "";
    if (cellval != null) {
        var date = new Date(parseInt(dateVal.replace("/Date(", "").replace(")/", ""), 10));
        var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
        var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();

        var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
        var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
        var seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
        var datecheck = date.getFullYear();
        if (datecheck == 1) {
            return "";
        } else {
            return date.getFullYear() + "-" + month + "-" + currentDate;
        }

    }
}
//IsStandard 选中得值
function IsStandardCheck(index) {
    var box1 = document.getElementById("IsStandard" + index);
    var DetailList = $('#PurposeToolingTable').bootstrapTable('getData')[index];
    if (box1.checked) {
        if (DetailList != null) {
            DetailList.IsStandard = true;
        }
    } else {
        if (DetailList != null) {
            DetailList.IsStandard = false;
        }
    }
}
//ToolingTypeCheck 选择
function ToolingTypeCheck(index) {
    var box1 = document.getElementById("ToolingType" + index);
    var DetailList = $('#PurposeToolingTable').bootstrapTable('getData')[index];
    if (box1.checked) {
        if (DetailList != null) {
            DetailList.ToolingType = true;
        }
    } else {
        if (DetailList != null) {
            DetailList.ToolingType = false;
        }
    }
}

//选择时间后
function QualificationsPassDateCheck(index) {
    var PassDate = document.getElementById("PassDate" + index);
    var Value = PassDate.value;
    var QualificationsList = $('#QualificationsTable').bootstrapTable('getData')[index];
    if (QualificationsList != null) {
        QualificationsList.PassDate = Value;
    }
}
function QualificationsBeginDateCheck(index) {
    var BeginDate = document.getElementById("BeginDate" + index);
    var Value = BeginDate.value;
    var QualificationsList = $('#QualificationsTable').bootstrapTable('getData')[index];
    if (QualificationsList != null) {
        QualificationsList.BeginDate = Value;
    }
}
function QualificationsEndDateCheck(index) {
    var EndDate = document.getElementById("EndDate" + index);
    var Value = EndDate.value;
    var QualificationsList = $('#QualificationsTable').bootstrapTable('getData')[index];
    if (QualificationsList != null) {
        QualificationsList.EndDate = Value;
    }
}
function EquipmentManufactureDateCheck(index) {
    var ManufactureDate = document.getElementById("ManufactureDate" + index);
    var Value = ManufactureDate.value;
    var EquipmentTableList = $('#EquipmentTable').bootstrapTable('getData')[index];
    if (EquipmentTableList != null) {
        EquipmentTableList.ManufactureDate = Value;
    }
}

//增行
function addRowbtn(rowIndex) {
    $("#ContactTable").bootstrapTable('editComplete');
    var data = {
    };
    $('#ContactTable').bootstrapTable('append', data);
}
function addRowbtnBuesiness(rowIndex) {
    $("#BusinessTable").bootstrapTable('editComplete');
    var data = {
    };
    $('#BusinessTable').bootstrapTable('append', data);
}
function addRowbtnFinancial(rowIndex) {
    $("#FinancialTable").bootstrapTable('editComplete');
    var data = {
    };
    $('#FinancialTable').bootstrapTable('append', data);
}
function addRowbtnCapital(rowIndex) {
    $("#CapitalTable").bootstrapTable('editComplete');
    var data = {
    };
    $('#CapitalTable').bootstrapTable('append', data);
}
function addRowbtnPeople(rowIndex) {
    $("#PeopleTable").bootstrapTable('editComplete');
    var data = {
    };
    $('#PeopleTable').bootstrapTable('append', data);
}
function addRowbtnQualifications(rowIndex) {
    $("#QualificationsTable").bootstrapTable('editComplete');
    var data = {
    };
    $('#QualificationsTable').bootstrapTable('append', data);
}
function addRowbtnOperating(rowIndex) {
    $("#OperatingTable").bootstrapTable('editComplete');
    var data = {
    };
    $('#OperatingTable').bootstrapTable('append', data);
}
function addRowbtnCustomer(rowIndex) {
    $("#CustomerTable").bootstrapTable('editComplete');
    var data = {
    };
    $('#CustomerTable').bootstrapTable('append', data);
}
function addRowbtnProduct(rowIndex) {
    $("#ProductTable").bootstrapTable('editComplete');
    var data = {
    };
    $('#ProductTable').bootstrapTable('append', data);
}
function addRowbtnQuality(rowIndex) {
    $("#QualityTable").bootstrapTable('editComplete');
    var data = {
    };
    $('#QualityTable').bootstrapTable('append', data);
}
function addRowbtnEquipment(rowIndex) {
    $("#EquipmentTable").bootstrapTable('editComplete');
    var data = {
    };
    $('#EquipmentTable').bootstrapTable('append', data);
}
function addRowbtnDetection(rowIndex) {
    $("#DetectionTable").bootstrapTable('editComplete');
    var data = {
    };
    $('#DetectionTable').bootstrapTable('append', data);
}
function addRowbtnOther(rowIndex) {
    $("#OtherTable").bootstrapTable('editComplete');
    var data = {
    };
    $('#OtherTable').bootstrapTable('append', data);
}
function addRowbtnTooling(rowIndex) {
    $("#PurposeToolingTable").bootstrapTable('editComplete');
    var data = {
    };
    $('#PurposeToolingTable').bootstrapTable('append', data);
}
//删行
function removeRowTooling(rowIndex) {
    $('#PurposeToolingTable').bootstrapTable('removeRow', rowIndex);
}
function removeRow(rowIndex) {
    $('#ContactTable').bootstrapTable('removeRow', rowIndex);
}
function removeRowBusiness(rowIndex) {
    $('#BusinessTable').bootstrapTable('removeRow', rowIndex);
}
function removeRowFinancial(rowIndex) {
    $('#FinancialTable').bootstrapTable('removeRow', rowIndex);
}
function removeRowCapital(rowIndex) {
    $('#CapitalTable').bootstrapTable('removeRow', rowIndex);
}
function removeRowPeople(rowIndex) {
    $('#PeopleTable').bootstrapTable('removeRow', rowIndex);
}
function removeRowQualifications(rowIndex) {
    $('#QualificationsTable').bootstrapTable('removeRow', rowIndex);
}
function removeRowOperating(rowIndex) {
    $('#OperatingTable').bootstrapTable('removeRow', rowIndex);
}
function removeRowCustomer(rowIndex) {
    $('#CustomerTable').bootstrapTable('removeRow', rowIndex);
}
function removeRowProduct(rowIndex) {
    $('#ProductTable').bootstrapTable('removeRow', rowIndex);
}
function removeRowQuality(rowIndex) {
    $('#QualityTable').bootstrapTable('removeRow', rowIndex);
}
function removeRowEquipment(rowIndex) {
    $('#EquipmentTable').bootstrapTable('removeRow', rowIndex);
}
function removeRowDetection(rowIndex) {
    $('#DetectionTable').bootstrapTable('removeRow', rowIndex);
}
function removeRowOther(rowIndex) {
    $('#OtherTable').bootstrapTable('removeRow', rowIndex);
}


